package com.tanqidi.arcgisandroid.ui.layerConfig

import androidx.lifecycle.ViewModel
import com.tanqidi.arcgisandroid.data.featureServer.ArcgisRepository
import com.tanqidi.arcgisandroid.data.featureServer.bean.ArcgisFeatureLayer
import com.tanqidi.arcgisandroid.data.featureServer.bean.ArcgisFeatureServer
import com.tanqidi.arcgisandroid.data.project.Project
import com.tanqidi.arcgisandroid.data.project.ProjectRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class LayerConfigViewModel @Inject constructor(
    private val projectRepository: ProjectRepository,
    private val arcgisRepository: ArcgisRepository
) : ViewModel() {
    fun getProjectByName(name: String): Project {
        return projectRepository.getProjectByName(name)
    }

    fun saveProject(project: Project) {
        projectRepository.saveProject(project)
    }

    suspend fun getArcgisFeatureServerByUrl(url: String) : ArcgisFeatureServer {
        return arcgisRepository.getArcgisFeatureServerByUrl(url)
    }

    suspend fun getArcgisFeatureLayerByUrl(url: String):ArcgisFeatureLayer {
        return arcgisRepository.getArcgisFeatureLayerByUrl(url)
    }
}